package variable

/** 认识变量 */

import "fmt"

/*
 * 定义内部函数
 */
func case1() {
	// 声明一个int 类型的变量
	var age int
	fmt.Println("age = ", age)

	// 为变量赋值
	age = 18
	fmt.Println("age = ", age)

	// 声明一个变量并初始化
	var num int = 99
	fmt.Println("num = ", num)

	// 当变量有初始值，是可以推论出数据类型
	var number = 88
	fmt.Printf("number = %d , type=%T \n", number, number)

	// 声明多个变量
	var with, heigth int = 120, 240
	fmt.Println("with = ; ", with, "heigth = ", heigth)

	// 声明多个变量不同类型
	var (
		userName   = "Bob"
		userAge    = 30
		userHeight = 175.8
		isActive   = true
	)
	fmt.Println("userName = ", userName, "userAge = ", userAge, "userHeight = ", userHeight, "isActive = ", isActive)

	// 简短声明变量
	pName := "丽丽"
	fmt.Println("pName = ", pName)

	// 简短声明多个变量
	pAge, pSex := 18, true
	fmt.Println("pAge = ", pAge)
	fmt.Println("pSex = ", pSex)
}

/*
 * 提供外部访问函数
 */
func Test() {
	case1()
}
